/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package evaluation.ged;

import evaluation.Edge;
import util.StringSimWrapper;

/**
 *
 * @author phong
 */
public class EdgeSubstitution extends EditOperation {
    Edge oldE, newE;

    public EdgeSubstitution(Edge v1, Edge v2) {
        this.oldE = v1;
        this.newE = v2;
    }
    
    public Edge getOldEdge() {
        return this.oldE;
    }
    
    public Edge getNewEdge() {
        return this.newE;
    }
        
    @Override
    public double getCost() {
        //return 1 - StringSimWrapper.calSim(oldE.getLabel(), newE.getLabel());            
        return (oldE.getLabel().equals(newE.getLabel()) ? 0 : 1);
    }
    
    @Override
    public boolean equals(Object o) {
        if (o instanceof EdgeSubstitution) {
            EdgeSubstitution that = (EdgeSubstitution)o;
            return that.newE.equals(this.newE) && that.oldE.equals(this.oldE);
        }
        return false;
    }
    
    @Override
    public int hashCode() {
        return this.newE.hashCode() * 31 + this.oldE.hashCode() * 17 + "vertexsubstitution".hashCode();
    }
    
    @Override
    public String toString() {
        return "Sub(" + this.oldE.toString() + "," + this.newE.toString() + ") with cost " + this.getCost();
    }
}

